From 00f6f48d3923a213fdc8e49529f627d4bbf2210c Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Sun, 21 Aug 2005 16:39:56 +0000 Subject: [PATCH] naming cleanup --- ChangeLog | 23 ++++ babl/babl-classes.h | 25 +++- babl/babl-fish.c | 79 +++++++++---- babl/babl-ids.h | 45 ++++---- babl/base/babl-base.c | 18 +-- babl/base/model-gray.c | 224 ++++++++++++++++++++---------------- babl/base/model-grayscale.c | 224 ++++++++++++++++++++---------------- babl/base/model-lab.c | 15 ++- babl/base/model-rgb.c | 37 +++--- babl/base/model-ycbcr.c | 10 +- tests/float_to_u8.c | 8 +- tests/grayscale_to_rgb.c | 10 +- tests/rgb_to_lab_to_rgb.c | 12 +- tests/rgb_to_ycbcr.c | 12 +- tests/rgb_to_ycbcr_to_rgb.c | 12 +- tests/u8_to_float.c | 8 +- 16 files changed, 450 insertions(+), 312 deletions(-) diff --git a/ChangeLog b/ChangeLog index fccf39a..70af250 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2005-08-21 Øyvind Kolås + + * babl/babl-classes.h: reindent, some documentation. + * babl/babl-fish.c: (babl_fish_reference_new): assertions for + arguments. + * babl/babl-ids.h: cleanup. + * babl/base/babl-base.c: (models): grayscale->gray + * babl/base/model-grayscale.c: (babl_base_model_gray), + (components), (models), (rgb_to_gray), (rgb_to_gray_2_2), + (gray_2_2_to_rgb), (gray_to_rgb), + (gray_alpha_premultiplied_to_rgba), + (rgba_to_gray_alpha_premultiplied), (conversions): grayscale->gray, + added gamma-2.2 with alpha. + * babl/base/model-lab.c: + * babl/base/model-rgb.c: + * babl/base/model-ycbcr.c: Name normalizations + * tests/float_to_u8.c: (test_float_to_rgb_u8): + * tests/grayscale_to_rgb.c: (test): + * tests/rgb_to_lab_to_rgb.c: (test): + * tests/rgb_to_ycbcr.c: (test): + * tests/rgb_to_ycbcr_to_rgb.c: (test): + * tests/u8_to_float.c: (test): Name synchronization. + 2005-08-18 Øyvind Kolås * babl/base/util.h: added new and hopefully correct gamma correction diff --git a/babl/babl-classes.h b/babl/babl-classes.h index a11f2ae..2ac7b94 100644 --- a/babl/babl-classes.h +++ b/babl/babl-classes.h @@ -87,7 +87,7 @@ typedef struct } BablInstance; typedef struct -{ +BablConversion { BablInstance instance; union Babl *source; union Babl *destination; @@ -101,9 +101,10 @@ typedef struct } function; } BablConversion; -typedef struct -{ - BablConversion conversion; +typedef struct { + BablConversion conversion; + BablConversion *from_double; + BablConversion *to_double; } BablConversionType; typedef struct @@ -195,9 +196,25 @@ typedef struct union Babl *destination; } BablFish; + +/* a BablFish which is a reference babl fish relies on the double + * versions that are required to exist for maximum sanity. + * + * A BablFishReference is not intended to be fast, thus the algorithm + * encoded can use a multi stage approach, where some of the stages could + * be completely removed for optimization reasons. + * + * This is not the intention of the "BablFishReference factory", it's + * implementation is meant to be kept as small as possible wrt logic. + * + * One of the contributions that would be welcome are new fish factories. + */ + + typedef struct { BablFish fish; + BablConversion *type_to_double; BablConversion *model_to_rgba; BablConversion *rgba_to_model; diff --git a/babl/babl-fish.c b/babl/babl-fish.c index 403bb91..fdb06a2 100644 --- a/babl/babl-fish.c +++ b/babl/babl-fish.c @@ -124,36 +124,67 @@ babl_fish_reference_new (Babl *source, assert (BABL_IS_BABL (source)); assert (BABL_IS_BABL (destination)); + assert (source->class_type == BABL_PIXEL_FORMAT || + source->class_type == BABL_MODEL); + assert (destination->class_type == BABL_PIXEL_FORMAT || + destination->class_type == BABL_MODEL); + babl = babl_calloc (sizeof (BablFishReference), 1); babl->class_type = BABL_FISH_REFERENCE; babl->instance.id = 0; babl->instance.name = NULL; babl->fish.source = (union Babl*)source; babl->fish.destination = (union Babl*)destination; - - babl->reference_fish.type_to_double = - babl_conversion_find ( - source->pixel_format.type[0], - babl_type_id (BABL_DOUBLE) - ); - - babl->reference_fish.model_to_rgba = - babl_conversion_find ( - source->pixel_format.model[0], - babl_model_id (BABL_RGBA) - ); - - babl->reference_fish.rgba_to_model = - babl_conversion_find ( - babl_model_id (BABL_RGBA), - destination->pixel_format.model[0] - ); - - babl->reference_fish.double_to_type = - babl_conversion_find ( - babl_type_id (BABL_DOUBLE), - destination->pixel_format.type[0] - ); + + if (source->class_type == BABL_PIXEL_FORMAT) + { + babl->reference_fish.type_to_double = + babl_conversion_find ( + source->pixel_format.type[0], + babl_type_id (BABL_DOUBLE) + ); + + babl->reference_fish.model_to_rgba = + babl_conversion_find ( + source->pixel_format.model[0], + babl_model_id (BABL_RGBA) + ); + + babl->reference_fish.rgba_to_model = + babl_conversion_find ( + babl_model_id (BABL_RGBA), + destination->pixel_format.model[0] + ); + + babl->reference_fish.double_to_type = + babl_conversion_find ( + babl_type_id (BABL_DOUBLE), + destination->pixel_format.type[0] + ); + } + else if (source->class_type == BABL_MODEL) + { + babl->reference_fish.type_to_double = NULL; + + + babl->reference_fish.model_to_rgba = + babl_conversion_find ( + source->pixel_format.model[0], + babl_model_id (BABL_RGBA) + ); + + babl->reference_fish.rgba_to_model = + babl_conversion_find ( + babl_model_id (BABL_RGBA), + destination->pixel_format.model[0] + ); + + babl->reference_fish.double_to_type = + babl_conversion_find ( + babl_type_id (BABL_DOUBLE), + destination->pixel_format.type[0] + ); + } if (db_insert (babl) == babl) { diff --git a/babl/babl-ids.h b/babl/babl-ids.h index 9f6f331..4a882eb 100644 --- a/babl/babl-ids.h +++ b/babl/babl-ids.h @@ -34,47 +34,48 @@ enum { BABL_GREEN, BABL_BLUE, BABL_ALPHA, - BABL_LUMINANCE, - BABL_LUMINANCE_GAMMA_2_2, - BABL_LUMINANCE_MUL_ALPHA, BABL_RED_MUL_ALPHA, BABL_GREEN_MUL_ALPHA, BABL_BLUE_MUL_ALPHA, BABL_RED_GAMMA_2_2, BABL_GREEN_GAMMA_2_2, BABL_BLUE_GAMMA_2_2, + BABL_LUMINANCE, + BABL_LUMINANCE_GAMMA_2_2, + BABL_LUMINANCE_MUL_ALPHA, + BABL_X, + BABL_Y, + BABL_Z, + BABL_LAB_L, + BABL_LAB_A, + BABL_LAB_B, + BABL_CB, + BABL_CR, BABL_CYAN, BABL_MAGENTA, BABL_YELLOW, BABL_KEY, - BABL_CB, - BABL_CR, - BABL_LAB_L, - BABL_LAB_A, - BABL_LAB_B, - BABL_X, - BABL_Y, - BABL_Z, BABL_Z_BUFFER, BABL_PADDING, BABL_MODEL_BASE = 10000, BABL_RGB, - BABL_RGB_GAMMA_2_2, BABL_RGBA, + BABL_RGB_GAMMA_2_2, BABL_RGBA_GAMMA_2_2, BABL_RGBA_PREMULTIPLIED, - BABL_GRAYSCALE, - BABL_GRAYSCALE_GAMMA_2_2, - BABL_GRAYSCALE_ALPHA, - BABL_GRAYSCALE_ALPHA_PREMULTIPLIED, + BABL_GRAY, + BABL_GRAY_ALPHA, + BABL_GRAY_GAMMA_2_2, + BABL_GRAY_GAMMA_2_2_ALPHA, + BABL_GRAY_ALPHA_PREMULTIPLIED, BABL_YCBCR, - BABL_YCBCRA, + BABL_YCBCR_ALPHA, BABL_LAB, BABL_LAB_ALPHA, BABL_CMY, BABL_CMYK, - BABL_CMYKA, + BABL_CMYK_ALPHA, BABL_PIXEL_FORMAT_BASE = 100000, BABL_SRGB, @@ -82,17 +83,15 @@ enum { BABL_RGB_FLOAT, BABL_RGBA_FLOAT, BABL_RGBA_DOUBLE, - BABL_CMYK_FLOAT, - BABL_CMYKA_FLOAT, + BABL_LAB_FLOAT, BABL_YUV420, -#if 0 BABL_RGB_U8, BABL_RGBA_U8, BABL_RGBA_U16, - BABL_RGBA_FLOAT, + BABL_CMYK_FLOAT, + BABL_CMYK_ALPHA_FLOAT, BABL_YUV411, BABL_YUV422, -#endif BABL_PIXEL_USER_BASE, }; diff --git a/babl/base/babl-base.c b/babl/base/babl-base.c index 68050cd..010bbb1 100644 --- a/babl/base/babl-base.c +++ b/babl/base/babl-base.c @@ -62,18 +62,18 @@ types (void) * models */ -void babl_base_model_rgb (void); -void babl_base_model_grayscale (void); -void babl_base_model_ycbcr (void); -void babl_base_model_lab (void); +void babl_base_model_rgb (void); +void babl_base_model_gray (void); +void babl_base_model_ycbcr (void); +void babl_base_model_lab (void); static void models (void) { - babl_base_model_rgb (); /* must be registered first since it is the - reference */ - babl_base_model_grayscale (); - babl_base_model_lab (); - babl_base_model_ycbcr (); + babl_base_model_rgb (); /* must be registered first since it is the + reference, (and contains the alpha definition) */ + babl_base_model_gray (); + babl_base_model_lab (); + babl_base_model_ycbcr (); } diff --git a/babl/base/model-gray.c b/babl/base/model-gray.c index 821a75e..5c1dd35 100644 --- a/babl/base/model-gray.c +++ b/babl/base/model-gray.c @@ -17,6 +17,8 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME: this file should be renamed model-gray.c */ + #include "babl.h" #include "util.h" #include "rgb-constants.h" @@ -26,7 +28,7 @@ static void components (void); static void models (void); static void conversions (void); -void babl_base_model_grayscale (void) +void babl_base_model_gray (void) { components (); models (); @@ -37,13 +39,19 @@ static void components (void) { babl_component_new ( - "luminance", + "Y", "id", BABL_LUMINANCE, "luma", NULL); babl_component_new ( - "luminance-gamma2.2", + "Y*A", + "id", BABL_LUMINANCE_MUL_ALPHA, + "luma", + NULL); + + babl_component_new ( + "Y-g2.2", "id", BABL_LUMINANCE_GAMMA_2_2, "luma", NULL); @@ -53,27 +61,34 @@ static void models (void) { babl_model_new ( - "grayscale", - "id", BABL_GRAYSCALE, + "gray", + "id", BABL_GRAY, babl_component_id (BABL_LUMINANCE), NULL); babl_model_new ( - "grayscale-gamma2.2", - "id", BABL_GRAYSCALE_GAMMA_2_2, - babl_component_id (BABL_LUMINANCE), + "gray-g2.2", + "id", BABL_GRAY_GAMMA_2_2, + babl_component_id (BABL_LUMINANCE_GAMMA_2_2), NULL); babl_model_new ( - "grayscale-alpha", - "id", BABL_GRAYSCALE_ALPHA, + "graya-g2.2", + "id", BABL_GRAY_GAMMA_2_2_ALPHA, + babl_component_id (BABL_LUMINANCE_GAMMA_2_2), + babl_component_id (BABL_ALPHA), + NULL); + + babl_model_new ( + "graya", + "id", BABL_GRAY_ALPHA, babl_component_id (BABL_LUMINANCE), babl_component_id (BABL_ALPHA), NULL); babl_model_new ( - "grayscale-alpha-premultiplied", - "id", BABL_GRAYSCALE_ALPHA_PREMULTIPLIED, + "grayA", + "id", BABL_GRAY_ALPHA_PREMULTIPLIED, babl_component_id (BABL_LUMINANCE_MUL_ALPHA), babl_component_id (BABL_ALPHA), NULL); @@ -82,13 +97,13 @@ models (void) static void -rgb_to_grayscale (int src_bands, - void **src, - int *src_pitch, - int dst_bands, - void **dst, - int *dst_pitch, - int n) +rgb_to_gray (int src_bands, + void **src, + int *src_pitch, + int dst_bands, + void **dst, + int *dst_pitch, + int n) { BABL_PLANAR_SANITY while (n--) @@ -118,13 +133,13 @@ rgb_to_grayscale (int src_bands, static void -rgb_to_grayscale_2_2 (int src_bands, - void **src, - int *src_pitch, - int dst_bands, - void **dst, - int *dst_pitch, - int n) +rgb_to_gray_2_2 (int src_bands, + void **src, + int *src_pitch, + int dst_bands, + void **dst, + int *dst_pitch, + int n) { BABL_PLANAR_SANITY while (n--) @@ -154,13 +169,13 @@ rgb_to_grayscale_2_2 (int src_bands, static void -grayscale_2_2_to_rgb (int src_bands, - void **src, - int *src_pitch, - int dst_bands, - void **dst, - int *dst_pitch, - int n) +gray_2_2_to_rgb (int src_bands, + void **src, + int *src_pitch, + int dst_bands, + void **dst, + int *dst_pitch, + int n) { BABL_PLANAR_SANITY while (n--) @@ -192,13 +207,13 @@ grayscale_2_2_to_rgb (int src_bands, static void -grayscale_to_rgb (int src_bands, - void **src, - int *src_pitch, - int dst_bands, - void **dst, - int *dst_pitch, - int n) +gray_to_rgb (int src_bands, + void **src, + int *src_pitch, + int dst_bands, + void **dst, + int *dst_pitch, + int n) { BABL_PLANAR_SANITY while (n--) @@ -228,13 +243,13 @@ grayscale_to_rgb (int src_bands, } static void -grayscale_alpha_premultiplied_to_rgba (int src_bands, - void **src, - int *src_pitch, - int dst_bands, - void **dst, - int *dst_pitch, - int n) +gray_alpha_premultiplied_to_rgba (int src_bands, + void **src, + int *src_pitch, + int dst_bands, + void **dst, + int *dst_pitch, + int n) { BABL_PLANAR_SANITY assert (src_bands == 2); @@ -264,13 +279,13 @@ grayscale_alpha_premultiplied_to_rgba (int src_bands, static void -rgba_to_grayscale_alpha_premultiplied (int src_bands, - void **src, - int *src_pitch, - int dst_bands, - void **dst, - int *dst_pitch, - int n) +rgba_to_gray_alpha_premultiplied (int src_bands, + void **src, + int *src_pitch, + int dst_bands, + void **dst, + int *dst_pitch, + int n) { BABL_PLANAR_SANITY; assert (src_bands == 4); @@ -361,114 +376,131 @@ static void conversions (void) { babl_conversion_new ( - "babl-base: grayscale-gamma2.2 to rgba", - "source", babl_model_id (BABL_GRAYSCALE_GAMMA_2_2), + "babl-base: gray-g2.2 to rgba", + "source", babl_model_id (BABL_GRAY_GAMMA_2_2), + "destination", babl_model_id (BABL_RGBA), + "planar", gray_2_2_to_rgb, + NULL + ); + + + babl_conversion_new ( + "babl-base: rgba to gray-g2.2", + "source", babl_model_id (BABL_RGBA), + "destination", babl_model_id (BABL_GRAY_GAMMA_2_2), + "planar", rgb_to_gray_2_2, + NULL + ); + + babl_conversion_new ( + "babl-base: graya-g2.2 to rgba", + "source", babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA), "destination", babl_model_id (BABL_RGBA), - "planar", grayscale_2_2_to_rgb, + "planar", gray_2_2_to_rgb, NULL ); babl_conversion_new ( - "babl-base: rgba to grayscale-gamma2.2", + "babl-base: rgba to graya-g2.2", "source", babl_model_id (BABL_RGBA), - "destination", babl_model_id (BABL_GRAYSCALE_GAMMA_2_2), - "planar", rgb_to_grayscale_2_2, + "destination", babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA), + "planar", rgb_to_gray_2_2, NULL ); babl_conversion_new ( - "babl-base: grayscale to rgba", - "source", babl_model_id (BABL_GRAYSCALE), + "babl-base: gray to rgba", + "source", babl_model_id (BABL_GRAY), "destination", babl_model_id (BABL_RGBA), - "planar", grayscale_to_rgb, + "planar", gray_to_rgb, NULL ); babl_conversion_new ( - "babl-base: grayscale to rgb", - "source", babl_model_id (BABL_GRAYSCALE), + "babl-base: gray to rgb", + "source", babl_model_id (BABL_GRAY), "destination", babl_model_id (BABL_RGB), - "planar", grayscale_to_rgb, + "planar", gray_to_rgb, NULL ); babl_conversion_new ( - "babl-base: grayscale-alpha to rgba", - "source", babl_model_id (BABL_GRAYSCALE_ALPHA), + "babl-base: gray-alpha to rgba", + "source", babl_model_id (BABL_GRAY_ALPHA), "destination", babl_model_id (BABL_RGBA), - "planar", grayscale_to_rgb, + "planar", gray_to_rgb, NULL ); babl_conversion_new ( - "babl-base: grayscale-alpha to rgb", - "source", babl_model_id (BABL_GRAYSCALE_ALPHA), + "babl-base: gray-alpha to rgb", + "source", babl_model_id (BABL_GRAY_ALPHA), "destination", babl_model_id (BABL_RGB), - "planar", grayscale_to_rgb, + "planar", gray_to_rgb, NULL ); babl_conversion_new ( - "babl-base: rgba to grayscale-alpha", + "babl-base: rgba to gray-alpha", "source", babl_model_id (BABL_RGBA), - "destination", babl_model_id (BABL_GRAYSCALE_ALPHA), - "planar", rgb_to_grayscale, + "destination", babl_model_id (BABL_GRAY_ALPHA), + "planar", rgb_to_gray, NULL ); babl_conversion_new ( - "babl-base: rgba to grayscale", + "babl-base: rgba to gray", "source", babl_model_id (BABL_RGBA), - "destination", babl_model_id (BABL_GRAYSCALE), - "planar", rgb_to_grayscale, + "destination", babl_model_id (BABL_GRAY), + "planar", rgb_to_gray, NULL ); babl_conversion_new ( - "babl-base: rgb to grayscale-alpha", + "babl-base: rgb to gray-alpha", "source", babl_model_id (BABL_RGB), - "destination", babl_model_id (BABL_GRAYSCALE_ALPHA), - "planar", rgb_to_grayscale, + "destination", babl_model_id (BABL_GRAY_ALPHA), + "planar", rgb_to_gray, NULL ); babl_conversion_new ( - "babl-base: rgb to grayscale", + "babl-base: rgb to gray", "source", babl_model_id (BABL_RGB), - "destination", babl_model_id (BABL_GRAYSCALE), - "planar", rgb_to_grayscale, + "destination", babl_model_id (BABL_GRAY), + "planar", rgb_to_gray, NULL ); babl_conversion_new ( - "babl-base: grayscale-alpha to grayscale-alpha-premultiplied", - "source", babl_model_id (BABL_GRAYSCALE_ALPHA), - "destination", babl_model_id (BABL_GRAYSCALE_ALPHA_PREMULTIPLIED), + "babl-base: gray-alpha to gray-alpha-premultiplied", + "source", babl_model_id (BABL_GRAY_ALPHA), + "destination", babl_model_id (BABL_GRAY_ALPHA_PREMULTIPLIED), "planar", non_premultiplied_to_premultiplied, NULL ); babl_conversion_new ( - "babl-base: grayscale-alpha-premultuplied to grayscale-alpha", - "source", babl_model_id (BABL_GRAYSCALE_ALPHA_PREMULTIPLIED), - "destination", babl_model_id (BABL_GRAYSCALE_ALPHA), + "babl-base: gray-alpha-premultuplied to gray-alpha", + "source", babl_model_id (BABL_GRAY_ALPHA_PREMULTIPLIED), + "destination", babl_model_id (BABL_GRAY_ALPHA), "planar", premultiplied_to_non_premultiplied, NULL ); babl_conversion_new ( - "babl-base: grayscale-alpha-premultiplied to rgba", - "source", babl_model_id (BABL_GRAYSCALE_ALPHA_PREMULTIPLIED), + "babl-base: gray-alpha-premultiplied to rgba", + "source", babl_model_id (BABL_GRAY_ALPHA_PREMULTIPLIED), "destination", babl_model_id (BABL_RGBA), - "planar", grayscale_alpha_premultiplied_to_rgba, + "planar", gray_alpha_premultiplied_to_rgba, NULL ); babl_conversion_new ( - "babl-base: rgba to grayscale-alpha-premultiplied", + "babl-base: rgba to gray-alpha-premultiplied", "source", babl_model_id (BABL_RGBA), - "destination", babl_model_id (BABL_GRAYSCALE_ALPHA_PREMULTIPLIED), - "planar", rgba_to_grayscale_alpha_premultiplied, + "destination", babl_model_id (BABL_GRAY_ALPHA_PREMULTIPLIED), + "planar", rgba_to_gray_alpha_premultiplied, NULL ); } diff --git a/babl/base/model-grayscale.c b/babl/base/model-grayscale.c index 821a75e..5c1dd35 100644 --- a/babl/base/model-grayscale.c +++ b/babl/base/model-grayscale.c @@ -17,6 +17,8 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME: this file should be renamed model-gray.c */ + #include "babl.h" #include "util.h" #include "rgb-constants.h" @@ -26,7 +28,7 @@ static void components (void); static void models (void); static void conversions (void); -void babl_base_model_grayscale (void) +void babl_base_model_gray (void) { components (); models (); @@ -37,13 +39,19 @@ static void components (void) { babl_component_new ( - "luminance", + "Y", "id", BABL_LUMINANCE, "luma", NULL); babl_component_new ( - "luminance-gamma2.2", + "Y*A", + "id", BABL_LUMINANCE_MUL_ALPHA, + "luma", + NULL); + + babl_component_new ( + "Y-g2.2", "id", BABL_LUMINANCE_GAMMA_2_2, "luma", NULL); @@ -53,27 +61,34 @@ static void models (void) { babl_model_new ( - "grayscale", - "id", BABL_GRAYSCALE, + "gray", + "id", BABL_GRAY, babl_component_id (BABL_LUMINANCE), NULL); babl_model_new ( - "grayscale-gamma2.2", - "id", BABL_GRAYSCALE_GAMMA_2_2, - babl_component_id (BABL_LUMINANCE), + "gray-g2.2", + "id", BABL_GRAY_GAMMA_2_2, + babl_component_id (BABL_LUMINANCE_GAMMA_2_2), NULL); babl_model_new ( - "grayscale-alpha", - "id", BABL_GRAYSCALE_ALPHA, + "graya-g2.2", + "id", BABL_GRAY_GAMMA_2_2_ALPHA, + babl_component_id (BABL_LUMINANCE_GAMMA_2_2), + babl_component_id (BABL_ALPHA), + NULL); + + babl_model_new ( + "graya", + "id", BABL_GRAY_ALPHA, babl_component_id (BABL_LUMINANCE), babl_component_id (BABL_ALPHA), NULL); babl_model_new ( - "grayscale-alpha-premultiplied", - "id", BABL_GRAYSCALE_ALPHA_PREMULTIPLIED, + "grayA", + "id", BABL_GRAY_ALPHA_PREMULTIPLIED, babl_component_id (BABL_LUMINANCE_MUL_ALPHA), babl_component_id (BABL_ALPHA), NULL); @@ -82,13 +97,13 @@ models (void) static void -rgb_to_grayscale (int src_bands, - void **src, - int *src_pitch, - int dst_bands, - void **dst, - int *dst_pitch, - int n) +rgb_to_gray (int src_bands, + void **src, + int *src_pitch, + int dst_bands, + void **dst, + int *dst_pitch, + int n) { BABL_PLANAR_SANITY while (n--) @@ -118,13 +133,13 @@ rgb_to_grayscale (int src_bands, static void -rgb_to_grayscale_2_2 (int src_bands, - void **src, - int *src_pitch, - int dst_bands, - void **dst, - int *dst_pitch, - int n) +rgb_to_gray_2_2 (int src_bands, + void **src, + int *src_pitch, + int dst_bands, + void **dst, + int *dst_pitch, + int n) { BABL_PLANAR_SANITY while (n--) @@ -154,13 +169,13 @@ rgb_to_grayscale_2_2 (int src_bands, static void -grayscale_2_2_to_rgb (int src_bands, - void **src, - int *src_pitch, - int dst_bands, - void **dst, - int *dst_pitch, - int n) +gray_2_2_to_rgb (int src_bands, + void **src, + int *src_pitch, + int dst_bands, + void **dst, + int *dst_pitch, + int n) { BABL_PLANAR_SANITY while (n--) @@ -192,13 +207,13 @@ grayscale_2_2_to_rgb (int src_bands, static void -grayscale_to_rgb (int src_bands, - void **src, - int *src_pitch, - int dst_bands, - void **dst, - int *dst_pitch, - int n) +gray_to_rgb (int src_bands, + void **src, + int *src_pitch, + int dst_bands, + void **dst, + int *dst_pitch, + int n) { BABL_PLANAR_SANITY while (n--) @@ -228,13 +243,13 @@ grayscale_to_rgb (int src_bands, } static void -grayscale_alpha_premultiplied_to_rgba (int src_bands, - void **src, - int *src_pitch, - int dst_bands, - void **dst, - int *dst_pitch, - int n) +gray_alpha_premultiplied_to_rgba (int src_bands, + void **src, + int *src_pitch, + int dst_bands, + void **dst, + int *dst_pitch, + int n) { BABL_PLANAR_SANITY assert (src_bands == 2); @@ -264,13 +279,13 @@ grayscale_alpha_premultiplied_to_rgba (int src_bands, static void -rgba_to_grayscale_alpha_premultiplied (int src_bands, - void **src, - int *src_pitch, - int dst_bands, - void **dst, - int *dst_pitch, - int n) +rgba_to_gray_alpha_premultiplied (int src_bands, + void **src, + int *src_pitch, + int dst_bands, + void **dst, + int *dst_pitch, + int n) { BABL_PLANAR_SANITY; assert (src_bands == 4); @@ -361,114 +376,131 @@ static void conversions (void) { babl_conversion_new ( - "babl-base: grayscale-gamma2.2 to rgba", - "source", babl_model_id (BABL_GRAYSCALE_GAMMA_2_2), + "babl-base: gray-g2.2 to rgba", + "source", babl_model_id (BABL_GRAY_GAMMA_2_2), + "destination", babl_model_id (BABL_RGBA), + "planar", gray_2_2_to_rgb, + NULL + ); + + + babl_conversion_new ( + "babl-base: rgba to gray-g2.2", + "source", babl_model_id (BABL_RGBA), + "destination", babl_model_id (BABL_GRAY_GAMMA_2_2), + "planar", rgb_to_gray_2_2, + NULL + ); + + babl_conversion_new ( + "babl-base: graya-g2.2 to rgba", + "source", babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA), "destination", babl_model_id (BABL_RGBA), - "planar", grayscale_2_2_to_rgb, + "planar", gray_2_2_to_rgb, NULL ); babl_conversion_new ( - "babl-base: rgba to grayscale-gamma2.2", + "babl-base: rgba to graya-g2.2", "source", babl_model_id (BABL_RGBA), - "destination", babl_model_id (BABL_GRAYSCALE_GAMMA_2_2), - "planar", rgb_to_grayscale_2_2, + "destination", babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA), + "planar", rgb_to_gray_2_2, NULL ); babl_conversion_new ( - "babl-base: grayscale to rgba", - "source", babl_model_id (BABL_GRAYSCALE), + "babl-base: gray to rgba", + "source", babl_model_id (BABL_GRAY), "destination", babl_model_id (BABL_RGBA), - "planar", grayscale_to_rgb, + "planar", gray_to_rgb, NULL ); babl_conversion_new ( - "babl-base: grayscale to rgb", - "source", babl_model_id (BABL_GRAYSCALE), + "babl-base: gray to rgb", + "source", babl_model_id (BABL_GRAY), "destination", babl_model_id (BABL_RGB), - "planar", grayscale_to_rgb, + "planar", gray_to_rgb, NULL ); babl_conversion_new ( - "babl-base: grayscale-alpha to rgba", - "source", babl_model_id (BABL_GRAYSCALE_ALPHA), + "babl-base: gray-alpha to rgba", + "source", babl_model_id (BABL_GRAY_ALPHA), "destination", babl_model_id (BABL_RGBA), - "planar", grayscale_to_rgb, + "planar", gray_to_rgb, NULL ); babl_conversion_new ( - "babl-base: grayscale-alpha to rgb", - "source", babl_model_id (BABL_GRAYSCALE_ALPHA), + "babl-base: gray-alpha to rgb", + "source", babl_model_id (BABL_GRAY_ALPHA), "destination", babl_model_id (BABL_RGB), - "planar", grayscale_to_rgb, + "planar", gray_to_rgb, NULL ); babl_conversion_new ( - "babl-base: rgba to grayscale-alpha", + "babl-base: rgba to gray-alpha", "source", babl_model_id (BABL_RGBA), - "destination", babl_model_id (BABL_GRAYSCALE_ALPHA), - "planar", rgb_to_grayscale, + "destination", babl_model_id (BABL_GRAY_ALPHA), + "planar", rgb_to_gray, NULL ); babl_conversion_new ( - "babl-base: rgba to grayscale", + "babl-base: rgba to gray", "source", babl_model_id (BABL_RGBA), - "destination", babl_model_id (BABL_GRAYSCALE), - "planar", rgb_to_grayscale, + "destination", babl_model_id (BABL_GRAY), + "planar", rgb_to_gray, NULL ); babl_conversion_new ( - "babl-base: rgb to grayscale-alpha", + "babl-base: rgb to gray-alpha", "source", babl_model_id (BABL_RGB), - "destination", babl_model_id (BABL_GRAYSCALE_ALPHA), - "planar", rgb_to_grayscale, + "destination", babl_model_id (BABL_GRAY_ALPHA), + "planar", rgb_to_gray, NULL ); babl_conversion_new ( - "babl-base: rgb to grayscale", + "babl-base: rgb to gray", "source", babl_model_id (BABL_RGB), - "destination", babl_model_id (BABL_GRAYSCALE), - "planar", rgb_to_grayscale, + "destination", babl_model_id (BABL_GRAY), + "planar", rgb_to_gray, NULL ); babl_conversion_new ( - "babl-base: grayscale-alpha to grayscale-alpha-premultiplied", - "source", babl_model_id (BABL_GRAYSCALE_ALPHA), - "destination", babl_model_id (BABL_GRAYSCALE_ALPHA_PREMULTIPLIED), + "babl-base: gray-alpha to gray-alpha-premultiplied", + "source", babl_model_id (BABL_GRAY_ALPHA), + "destination", babl_model_id (BABL_GRAY_ALPHA_PREMULTIPLIED), "planar", non_premultiplied_to_premultiplied, NULL ); babl_conversion_new ( - "babl-base: grayscale-alpha-premultuplied to grayscale-alpha", - "source", babl_model_id (BABL_GRAYSCALE_ALPHA_PREMULTIPLIED), - "destination", babl_model_id (BABL_GRAYSCALE_ALPHA), + "babl-base: gray-alpha-premultuplied to gray-alpha", + "source", babl_model_id (BABL_GRAY_ALPHA_PREMULTIPLIED), + "destination", babl_model_id (BABL_GRAY_ALPHA), "planar", premultiplied_to_non_premultiplied, NULL ); babl_conversion_new ( - "babl-base: grayscale-alpha-premultiplied to rgba", - "source", babl_model_id (BABL_GRAYSCALE_ALPHA_PREMULTIPLIED), + "babl-base: gray-alpha-premultiplied to rgba", + "source", babl_model_id (BABL_GRAY_ALPHA_PREMULTIPLIED), "destination", babl_model_id (BABL_RGBA), - "planar", grayscale_alpha_premultiplied_to_rgba, + "planar", gray_alpha_premultiplied_to_rgba, NULL ); babl_conversion_new ( - "babl-base: rgba to grayscale-alpha-premultiplied", + "babl-base: rgba to gray-alpha-premultiplied", "source", babl_model_id (BABL_RGBA), - "destination", babl_model_id (BABL_GRAYSCALE_ALPHA_PREMULTIPLIED), - "planar", rgba_to_grayscale_alpha_premultiplied, + "destination", babl_model_id (BABL_GRAY_ALPHA_PREMULTIPLIED), + "planar", rgba_to_gray_alpha_premultiplied, NULL ); } diff --git a/babl/base/model-lab.c b/babl/base/model-lab.c index f08cf9d..0f0729f 100644 --- a/babl/base/model-lab.c +++ b/babl/base/model-lab.c @@ -41,19 +41,19 @@ static void components (void) { babl_component_new ( - "L", + "CIE L", "id", BABL_LAB_L, "luma", NULL); babl_component_new ( - "a", + "CIE a", "id", BABL_LAB_A, "chroma", NULL); babl_component_new ( - "b", + "CIE b", "id", BABL_LAB_B, "chroma", NULL); @@ -194,4 +194,13 @@ conversions (void) static void pixel_formats (void) { + babl_pixel_format_new ( + "lab-float", + "id", BABL_LAB_FLOAT, + babl_model_id (BABL_LAB), + babl_type_id (BABL_FLOAT), + babl_component_id (BABL_LAB_L), + babl_component_id (BABL_LAB_A), + babl_component_id (BABL_LAB_B), + NULL); } diff --git a/babl/base/model-rgb.c b/babl/base/model-rgb.c index 15b63e6..96d4170 100644 --- a/babl/base/model-rgb.c +++ b/babl/base/model-rgb.c @@ -39,42 +39,42 @@ static void components (void) { babl_component_new ( - "red", + "R", "id", BABL_RED, "luma", "chroma", NULL); babl_component_new ( - "green", + "G", "id", BABL_GREEN, "luma", "chroma", NULL); babl_component_new ( - "blue", + "B", "id", BABL_BLUE, "luma", "chroma", NULL); babl_component_new ( - "red-gamma2.2", + "R-g2.2", "id", BABL_RED_GAMMA_2_2, "luma", "chroma", NULL); babl_component_new ( - "green-gamma2.2", + "G-g2.2", "id", BABL_GREEN_GAMMA_2_2, "luma", "chroma", NULL); babl_component_new ( - "blue-gamma2.2", + "B-g2.2", "id", BABL_BLUE_GAMMA_2_2, "luma", "chroma", @@ -82,38 +82,33 @@ components (void) babl_component_new ( - "alpha", + "A", "id", BABL_ALPHA, "alpha", NULL); babl_component_new ( - "red*alpha", + "R*A", "id", BABL_RED_MUL_ALPHA, "luma", "chroma", "alpha", NULL); babl_component_new ( - "green*alpha", + "G*A", "id", BABL_GREEN_MUL_ALPHA, "luma", "chroma", "alpha", NULL); babl_component_new ( - "blue*alpha", + "B*A", "id", BABL_BLUE_MUL_ALPHA, "luma", "chroma", "alpha", NULL); - babl_component_new ( - "luminance*alpha", - "id", BABL_LUMINANCE_MUL_ALPHA, - "luma", - NULL); } static void @@ -146,7 +141,7 @@ models (void) NULL); babl_model_new ( - "rgb-gamma2.2", + "rgb-g2.2", "id", BABL_RGB_GAMMA_2_2, babl_component_id (BABL_RED_GAMMA_2_2), babl_component_id (BABL_GREEN_GAMMA_2_2), @@ -154,7 +149,7 @@ models (void) NULL); babl_model_new ( - "rgba-gamma2.2", + "rgba-g2.2", "id", BABL_RGBA_GAMMA_2_2, babl_component_id (BABL_RED_GAMMA_2_2), babl_component_id (BABL_GREEN_GAMMA_2_2), @@ -317,7 +312,7 @@ conversions (void) ); babl_conversion_new ( - "babl-base: rgba to rgb-gamma2.2", + "babl-base: rgba to rgb-g2.2", "source", babl_model_id (BABL_RGBA), "destination", babl_model_id (BABL_RGB_GAMMA_2_2), "planar", g3_gamma_2_2, @@ -325,7 +320,7 @@ conversions (void) ); babl_conversion_new ( - "babl-base: rgba to rgba-gamma2.2", + "babl-base: rgba to rgba-g2.2", "source", babl_model_id (BABL_RGBA), "destination", babl_model_id (BABL_RGBA_GAMMA_2_2), "planar", g3_gamma_2_2, @@ -333,7 +328,7 @@ conversions (void) ); babl_conversion_new ( - "babl-base: rgb-gamma2.2 to rgba", + "babl-base: rgb-g2.2 to rgba", "source", babl_model_id (BABL_RGB_GAMMA_2_2), "destination", babl_model_id (BABL_RGBA), "planar", g3_inv_gamma_2_2, @@ -341,7 +336,7 @@ conversions (void) ); babl_conversion_new ( - "babl-base: rgba-gamma2.2 to rgba", + "babl-base: rgba-g2.2 to rgba", "source", babl_model_id (BABL_RGBA_GAMMA_2_2), "destination", babl_model_id (BABL_RGBA), "planar", g3_inv_gamma_2_2, diff --git a/babl/base/model-ycbcr.c b/babl/base/model-ycbcr.c index 3c2feba..d3c7b24 100644 --- a/babl/base/model-ycbcr.c +++ b/babl/base/model-ycbcr.c @@ -42,13 +42,13 @@ static void components (void) { babl_component_new ( - "cb", + "Cb", "id", BABL_CB, "chroma", NULL); babl_component_new ( - "cr", + "Cr", "id", BABL_CR, "chroma", NULL); @@ -67,7 +67,7 @@ models (void) babl_model_new ( "ycbcra", - "id", BABL_YCBCRA, + "id", BABL_YCBCR_ALPHA, babl_component_id (BABL_LUMINANCE_GAMMA_2_2), babl_component_id (BABL_CB), babl_component_id (BABL_CR), @@ -185,13 +185,13 @@ conversions (void) babl_conversion_new ( "babl-base: rgba to ycbcra", "source", babl_model_id (BABL_RGBA), - "destination", babl_model_id (BABL_YCBCRA), + "destination", babl_model_id (BABL_YCBCR_ALPHA), "planar", rgb_to_ycbcr, NULL ); babl_conversion_new ( "babl-base: ycbcra to rgba", - "source", babl_model_id (BABL_YCBCRA), + "source", babl_model_id (BABL_YCBCR_ALPHA), "destination", babl_model_id (BABL_RGBA), "planar", ycbcr_to_rgb, NULL diff --git a/tests/float_to_u8.c b/tests/float_to_u8.c index 86b9e4d..e1b4bd5 100644 --- a/tests/float_to_u8.c +++ b/tests/float_to_u8.c @@ -54,16 +54,16 @@ test_float_to_rgb_u8 (void) fish = babl_fish ( babl_pixel_format_new ( "foo", - babl_model ("grayscale"), + babl_model ("gray"), babl_type ("float"), - babl_component ("luminance"), + babl_component ("Y"), NULL ), babl_pixel_format_new ( "bar", - babl_model ("grayscale"), + babl_model ("gray"), babl_type ("u8"), - babl_component ("luminance"), + babl_component ("Y"), NULL )); diff --git a/tests/grayscale_to_rgb.c b/tests/grayscale_to_rgb.c index 367689d..6d51701 100644 --- a/tests/grayscale_to_rgb.c +++ b/tests/grayscale_to_rgb.c @@ -40,18 +40,18 @@ test (void) fish = babl_fish ( babl_pixel_format_new ( "foo", - babl_model ("grayscale"), + babl_model ("gray"), babl_type ("float"), - babl_component ("luminance"), + babl_component ("Y"), NULL ), babl_pixel_format_new ( "bar", babl_model ("rgb"), babl_type ("float"), - babl_component ("red"), - babl_component ("green"), - babl_component ("blue"), + babl_component ("R"), + babl_component ("G"), + babl_component ("B"), NULL ) ); diff --git a/tests/rgb_to_lab_to_rgb.c b/tests/rgb_to_lab_to_rgb.c index eec4f27..9c5f477 100644 --- a/tests/rgb_to_lab_to_rgb.c +++ b/tests/rgb_to_lab_to_rgb.c @@ -79,18 +79,18 @@ test (void) "foo", babl_model ("rgb"), babl_type ("float"), - babl_component ("red"), - babl_component ("green"), - babl_component ("blue"), + babl_component ("R"), + babl_component ("G"), + babl_component ("B"), NULL ), babl_pixel_format_new ( "bar", babl_model ("CIE Lab"), babl_type ("float"), - babl_component ("L"), - babl_component ("a"), - babl_component ("b"), + babl_component ("CIE L"), + babl_component ("CIE a"), + babl_component ("CIE b"), NULL ) ); diff --git a/tests/rgb_to_ycbcr.c b/tests/rgb_to_ycbcr.c index 1208698..11d03e7 100644 --- a/tests/rgb_to_ycbcr.c +++ b/tests/rgb_to_ycbcr.c @@ -56,18 +56,18 @@ test (void) "foo", babl_model ("rgb"), babl_type ("float"), - babl_component ("red"), - babl_component ("green"), - babl_component ("blue"), + babl_component ("R"), + babl_component ("G"), + babl_component ("B"), NULL ), babl_pixel_format_new ( "bar", babl_model ("ycbcr"), babl_type ("float"), - babl_component ("luminance"), - babl_component ("cb"), - babl_component ("cr"), + babl_component ("Y"), + babl_component ("Cb"), + babl_component ("Cr"), NULL ) ); diff --git a/tests/rgb_to_ycbcr_to_rgb.c b/tests/rgb_to_ycbcr_to_rgb.c index 4b324d2..57ee6e8 100644 --- a/tests/rgb_to_ycbcr_to_rgb.c +++ b/tests/rgb_to_ycbcr_to_rgb.c @@ -48,18 +48,18 @@ test (void) "foo", babl_model ("rgb"), babl_type ("float"), - babl_component ("red"), - babl_component ("green"), - babl_component ("blue"), + babl_component ("R"), + babl_component ("G"), + babl_component ("B"), NULL ), babl_pixel_format_new ( "bar", babl_model ("ycbcr"), babl_type ("float"), - babl_component ("luminance"), - babl_component ("cb"), - babl_component ("cr"), + babl_component ("Y"), + babl_component ("Cb"), + babl_component ("Cr"), NULL ) ); diff --git a/tests/u8_to_float.c b/tests/u8_to_float.c index e221021..7ffa2cb 100644 --- a/tests/u8_to_float.c +++ b/tests/u8_to_float.c @@ -39,16 +39,16 @@ test (void) fish = babl_fish ( babl_pixel_format_new ( "foo", - babl_model ("grayscale"), + babl_model ("gray"), babl_type ("u8"), - babl_component ("luminance"), + babl_component ("Y"), NULL ), babl_pixel_format_new ( "bar", - babl_model ("grayscale"), + babl_model ("gray"), babl_type ("float"), - babl_component ("luminance"), + babl_component ("Y"), NULL )); -- 2.30.2